Skip to content

fix(core): use running loop for FunctionTool executors#7883

Open
Ghraven wants to merge 1 commit into
microsoft:mainfrom
Ghraven:fix/function-tool-running-loop
Open

fix(core): use running loop for FunctionTool executors#7883
Ghraven wants to merge 1 commit into
microsoft:mainfrom
Ghraven:fix/function-tool-running-loop

Conversation

@Ghraven

@Ghraven Ghraven commented Jun 24, 2026

Copy link
Copy Markdown

Problem: FunctionTool.run() is already executing inside an async method, but the sync-function path asks the event loop policy via asyncio.get_event_loop() before dispatching work to the executor.

Before / after: before, both executor calls used asyncio.get_event_loop().run_in_executor(...). After, the method captures the active running loop once with asyncio.get_running_loop() and reuses it for both executor paths, while preserving cancellation-token linking and the existing executor behavior.

Verification:

  • python -m py_compile python\packages\autogen-core\src\autogen_core\tools\_function_tool.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant